@extends('layouts.default') @section('main')
    <script type="text/javascript" src="{{URL::asset('js/')}}/common.js"></script>
    <script type="text/javascript" src="{{URL::asset('js/')}}/ajaxfileupload.js"></script>

    <div id="content">
        <div id="content-header">
            <div id="breadcrumb">
                <a href="{{url('home')}}" title="返回首页" class="tip-bottom"><i
                            class="icon-home"></i> 首页</a>
                <a href="{{url('friendlink/list')}}" class="tip-bottom">友情链接管理</a>
                <a href="#" class="current">友情链接编辑</a>
            </div>
        </div>
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span9">
                    <div class="widget-box">
                        <div class="widget-title">
						<span class="icon"> <i class="icon-align-justify"></i>
						</span>
                            <h5>友情链接编辑</h5>
                        </div>
                        <div class="widget-content nopadding">
                            <form action="{{url('friendlink/edit')}}" id="adForm" method="post" class="form-horizontal">
                                <div class="control-group">
                                    <label class="control-label">链接ID :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="id" value="{{$list->id}}" readonly="readonly"  />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>链接名称 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="name" value="{{$list->name}}" placeholder="链接名称" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">logo图片 :</label>
                                    <div class="controls">
                                        <input type="hidden" class="span11" name="icon"
                                               placeholder="点击右边小图标上传" value="{{$list->icon}}" />
                                        <img src="{{getImage($list->icon)}}" width="120px" name="icon" height="120px"/>

                                        <a href="javascript:void(0);" id="uploadIconBtn"   onclick="javascript:openBrowse('uploadIconBtn','uploadIcon');">点击上传</a>
                                        <input type="file" id="uploadIcon" style="display:none" name="myfile" size="10" onchange="fileUpload('uploadIcon','icon')"/>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">背景图片 :</label>
                                    <div class="controls">
                                        <input type="hidden" class="span11" name="bg_icon"
                                               placeholder="点击右边小图标上传" value="{{$list->bg_icon}}" />
                                        <img src="{{getImage($list->bg_icon)}}" width="120px" name="bg_icon" height="120px"/>

                                        <a href="javascript:void(0);" id="uploadBgBtn"   onclick="javascript:openBrowse('uploadBgBtn','uploadBg');">点击上传</a>
                                        <input type="file" id="uploadBg" style="display:none" name="myfile" size="10" onchange="fileUpload('uploadBg','bg_icon')"/>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>url地址 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="url" value="{{$list->url}}" placeholder="url地址"  />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">排序 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="sort"  placeholder="排序（默认50，可修改）" value="{{$list->sort}}"  />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>链接类型 :</label>
                                    <div class="controls">
                                        <input type="radio"  name="category_code"  value="1" @if($list->category_code==1)checked="checked"@endif/>友情链接
                                        <input type="radio"  name="category_code"  value="2" @if($list->category_code==2)checked="checked"@endif/>合作伙伴
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>是否启用 :</label>
                                    <div class="controls">
                                        <input type="radio"  name="status"  value="1" @if($list->status==1)checked="checked"@endif/>启用
                                        <input type="radio"  name="status"  value="0" @if($list->status==0)checked="checked"@endif/>暂不
                                    </div>
                                </div>
                                <input type="hidden" class="span11" name="formType" value="edit" />
                                <div class="form-actions">
                                    <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                    <button type="button" id="doSave" class="btn btn-success">确认修改</button>
                                </div>
                            </form>
                            @include('errors.list')
                            @include('message.flash')
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        $("#doSave").click(function(){
            ajaxRequest($('#adForm').serializeArray(),$('#adForm').attr('action'),function(data){
                if(data.status){
                    alert(data.message);
                    window.location.href = data.forwardUrl;
                }else{
                    alert(data.message);
                }
            });
        });
    </script>
@stop
